﻿#if !SILVERLIGHT

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EffiProz.Core.Lib;
using EffiProz.Core.DataTypes;
using EffiProz.Core.Errors;
using EffiProz.Core.Persist;

namespace EffiProz.Core.RowIO
{
    public class RowInputBinaryDecode : RowInputBinary
    {
        Crypto crypto;

        public RowInputBinaryDecode(Crypto crypto, byte[] buf)
            : base(buf)
        {

            this.crypto = crypto;
        }

        public override Object[] readData(SqlType[] colTypes)
        {

            if (crypto != null)
            {
                int start = pos;
                int size = readInt();

                byte[] decoded = crypto.decode(buf, pos, size);
                Array.Copy(decoded, 0, buf, start, decoded.Length);

                pos = start;
            }

            return base.readData(colTypes);
        }
    }
}

#endif
